/*
 * @Author: your name
 * @Date: 2024-04-05 11:52:45
 * @LastEditTime: 2024-04-05 11:57:41
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \.leetcode\454.四数相加-ii.cpp
 */
/*
 * @lc app=leetcode.cn id=454 lang=cpp
 *
 * [454] 四数相加 II
 */

// @lc code=start
class Solution {
public:
    int fourSumCount(vector<int>& nums1, vector<int>& nums2, vector<int>& nums3, vector<int>& nums4) {
        unordered_map<int,int> map;
        int count = 0;
        for(auto num1:nums1){
            for(auto num2:nums2){
                map[num1+num2]++;
            }
        }
        for(auto num3:nums3){
            for(auto num4:nums4){
                if(map.find(0-(num3+num4))!=map.end()){
                    count+=map[0-(num3+num4)];
                }
            }
        }
        return count;
    }
};
// @lc code=end

